package com.example.havi.helper;

import android.content.Context;
import android.util.Log;

import com.example.havi.bean.EmojiBean;

import java.util.ArrayList;
import java.util.List;

/**
 * 表情定义
 */
public class EmojiDataHelper {

    public final static int[] codePoints ={
            0x1F600, 0x1F601, 0x1F602, 0x1F603, 0x1F604, 0x1F605, 0x1F606, 0x1F607, 0x1F608, 0x1F609, 0x1F610, 0x1F611
            , 0x1F612, 0x1F613, 0x1F614, 0x1F615, 0x1F616, 0x1F617, 0x1F618, 0x1F619, 0x1F620, 0x1F621, 0x1F622, 0x1F623
            , 0x1F624, 0x1F625, 0x1F626, 0x1F627, 0x1F628, 0x1F629, 0x1F630, 0x1F631, 0x1F632, 0x1F633, 0x1F634, 0x1F635
            , 0x1F636, 0x1F637, 0x1F60A, 0x1F60B, 0x1F60C, 0x1F60D, 0x1F60E, 0x1F60F, 0x1F61A, 0x1F61B, 0x1F61C, 0x1F61D
            , 0x1F61E, 0x1F61F, 0x1F62A, 0x1F62B, 0x1F62C, 0x1F62D, 0x1F62E, 0x1F62F
            , 0x1F63A, 0x1F63B, 0x1F63C, 0x1F63D, 0x1F63E, 0x1F63F
    };

    public final static String[] codePointsStrs = new String[]{
            "1f600", "1f601", "1f602", "1f603", "1f604", "1f605", "1f606", "1f607", "1f608", "1f609", "1f610", "1f611"
            , "1f612", "1f613", "1f614", "1f615", "1f616", "1f617", "1f618", "1f619", "1f620", "1f621", "1f622", "1f623"
            , "1f624", "1f625", "1f626", "1f627", "1f628", "1f629", "1f630", "1f631", "1f632", "1f633", "1f634", "1f635"
            , "1f636", "1f637", "1f60a", "1f60b", "1f60c", "1f60d", "1f60e", "1f60f", "1f61a", "1f61b", "1f61c", "1f61d"
            , "1f61e", "1f61f", "1f62a", "1f62b", "1f62c", "1f62d", "1f62e", "1f62f"
            , "1f63a", "1f63b", "1f63c", "1f63d", "1f63e", "1f63f"
    };


    private static EmojiDataHelper instence;

    public static EmojiDataHelper getInstence() {
        if (instence == null) {
            return new EmojiDataHelper();
        } else {
            return instence;
        }
    }
    private static List<EmojiBean> list = new ArrayList<>();
    public void init(Context context){
        for (int i = 0; i < codePoints.length; i++) {
            int codePoint = codePoints[i];
            String codePointsStr = codePointsStrs[i];
            String emojiStringByUnicode = getEmojiStringByUnicode(codePoint);
            int emojiDrawableId = context.getResources().getIdentifier("emoji_" + codePointsStr, "mipmap", context.getPackageName());
            list.add(new EmojiBean(emojiDrawableId,emojiStringByUnicode));
        }
    }

    private static String getEmojiStringByUnicode(int unicode) {
        return new String(Character.toChars(unicode));
    }

    public static List<EmojiBean> getEmojiData(){
        return list;
    }


}
